package com.bms.common.base.common.util;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import com.bms.common.base.common.exception.BusinessException;
import com.bms.common.base.common.exception.EnumSvrResult;


public class RenderUtil {

    /**
     * 转换json对象
     */
    public static void renderJson(HttpServletResponse response, Object jsonObject) {
        try {
            response.setContentType("application/json");
            response.setCharacterEncoding("UTF-8");
            PrintWriter writer = response.getWriter();
            writer.write(JsonUtil.getJsonFromObject(jsonObject));
        } catch (IOException e) {
            throw new BusinessException(EnumSvrResult.ERROR_CONVER_JSON);
        }
    }
}
